package com.bodu.core.common;

import com.bodu.core.entity.CommonEntity;
import com.bodu.core.entity.ParamReq;
import com.bodu.core.exception.custom.DeleteException;
import com.bodu.core.exception.custom.SaveException;
import com.bodu.core.exception.custom.SearchException;
import com.bodu.core.exception.custom.UpdateException;

import java.util.List;

/**
 * @author gaoya
 * @Description 基础Service
 * @date 2022 - 08 - 24 21:29:18
 */
public interface CommonService<R extends CommonEntity, V extends CommonEntity> {

    /**
     * 查询基本信息
     *
     * @param id
     * @return
     * @throws SearchException 查询异常
     */
    V getModel(Long id) throws SearchException;

    /**
     * 保存数据 返回主键值
     *
     * @param t
     * @return
     * @throws SaveException 保存异常
     */
    Long save(R t) throws SaveException;

    /**
     * 更新基础信息
     *
     * @return
     * @throws UpdateException 更新异常
     */
    Long update(R t) throws UpdateException;

    /**
     * 查询基础数据
     *
     * @param t
     * @return
     * @throws SearchException 查询异常
     */
    List<V> listPage(ParamReq<R> t) throws SearchException;

    /**
     * 查询基础数据量
     *
     * @param t
     * @return
     * @throws SearchException 查询异常
     */
    Integer countPage(ParamReq<R> t) throws SearchException;

    /**
     * 删除数据
     *
     * @param id
     * @return
     * @throws DeleteException 删除异常
     */
//    Integer delete(Long id) throws DeleteException;

    /**
     * 更新删除标志
     *
     * @param id
     * @param delFlag
     * @return
     * @throws DeleteException 删除异常
     */
    Integer updateDelFlagById(Long id, Integer delFlag) throws DeleteException;

    /**
     * 批量删除数据
     *
     * @param ids
     * @return
     * @throws DeleteException 删除异常
     */
//    Integer batchDelete(List<Long> ids) throws DeleteException;

}
